package com.suray.rgv.son.util;

/**
 * 子车动作执行结果
 */
public enum RgvSonActionResult {
    INVALID(-1, "无效"),
    INIT(0, "初始状态"),
    ACTION_FAIL(1, "执行失败"),
    ACTION_OK(2, "执行成功"),
    ACTION_ERROR(3, "执行异常");
    ;

    int value;
    String des;

    RgvSonActionResult(int value, String des) {
        this.value = value;
        this.des = des;
    }

    public int getValue() {
        return value;
    }

    public static RgvSonActionResult parseResult(int value) {
        if (value > ACTION_OK.value) {
            ACTION_ERROR.value = value;
            return ACTION_ERROR;
        }

        for (RgvSonActionResult rgvSonActionResult : RgvSonActionResult.values()) {
            if (rgvSonActionResult.value == value) {
                return rgvSonActionResult;
            }
        }

        return INVALID;
    }

    @Override
    public String toString() {
        return des;
    }
}
